package com.project.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.project.bean.UserBean;
import com.project.mapper.IUserMapper;
import com.project.service.IUserService;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

@Service
@Transactional
public class UserServiceImpl implements IUserService {
@Autowired
    private IUserMapper mapper;
    @Override
    public void register(UserBean user) {
        mapper.insert(user);
    }


    @Override
    public UserBean login(String username, String password) {
        QueryWrapper<UserBean> qw = new QueryWrapper<>();
        qw.eq("u_username",username);
        qw.eq("u_password",password);
        return mapper.selectOne(qw);
    }

    @Override
    public UserBean findByName(String username) {
        QueryWrapper<UserBean> qw = new QueryWrapper<>();
        qw.eq("u_username",username);
        return mapper.selectOne(qw);
    }
}
